﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Test;

public class SimpleClass
{ }
public class Example
{
    public static string GetStringEnvironmentArg(string argName)
    {
        string result = null;
        //string proj = Path.GetFullPath(Application.dataPath + "/../");

        var ss=System.Environment.GetCommandLineArgs();

        foreach (string item in System.Environment.GetCommandLineArgs())
        {

            if (item.StartsWith(argName))
            {
                result = item.Replace(argName, string.Empty);
            }
        }
        return result;
    }
    public static void Main()
    {
        A a = new A();
        a.Init();








        ////var clientLocal = Path.GetFullPath(Application.dataPath + "/../../..");//获取结对路劲
        //var clientLocal = "E:\\zhaoruibin\\Svn\\slg-client\\trunk";//获取结对路劲
        ////Debug.Log(clientLocal);//E:\zhaoruibin\Svn\slg-client\trunk
        //var client = "slg-client";
        //var design = "slg-design";
        //var apk = "slg-apk/Client";
        //var index = clientLocal.LastIndexOf(client);
        //Console.WriteLine(index);//首字母 也就是s 在clientLocal里面第一次遇到的索引值（每个字母索引 +1）
        //var aa = clientLocal.Remove(index);
        //Console.WriteLine(aa);

        #region 测试类型转换
        //string [] str= { "aa" };
        // var bundle2Ids = new Dictionary<string, int>();
        // bundle2Ids.Add("aa", 2);
        // var deps = Array.ConvertAll(str, input => bundle2Ids[input]);//sting =>int
        // Console.WriteLine("deps.Length: " + deps.Length);

        // for (int i = 0; i < deps.Length; i++)
        // {
        //     Console.WriteLine(deps[i]);

        // }
        #endregion

        #region 测试文件搜索 通配符
        //string searchPattern = "*.txt";
        //int index;
        //index = searchPattern.IndexOf("*", StringComparison.Ordinal);
        //Console.WriteLine(index);
        //searchPattern = searchPattern.Substring(index + 2);
        ////Console.WriteLine(searchPattern);
        //while ((index = searchPattern.IndexOf("..", StringComparison.Ordinal)) != -1)
        //{

        ////if (index + 2 == searchPattern.Length) // Terminal ".." . Files names cannot end in ".."
        ////    throw new ArgumentException(Environment.GetResourceString("Arg_InvalidSearchPattern"));

        ////if ((searchPattern[index + 2] == DirectorySeparatorChar)
        ////   || (searchPattern[index + 2] == AltDirectorySeparatorChar))
        ////    throw new ArgumentException(Environment.GetResourceString("Arg_InvalidSearchPattern"));

        //searchPattern = searchPattern.Substring(index + 2);
        //Console.WriteLine(searchPattern);
        //}
        #endregion

        //var path1 = System.AppDomain.CurrentDomain.BaseDirectory;//获取程序集目录
        //string path = Path.Combine(path1, "Image", "menu");//Path.Combine 将3个字符串组合成路径
        //var images = Directory.GetFiles(path, ".", 
        //    SearchOption.AllDirectories).Where(s => s.EndsWith(".png") || s.EndsWith(".jpg") || s.EndsWith(".gif"));


        //string searchPattern = "*.txt,*.bytes,*.json,*.csv,*.xml,*htm,*.html,*.yaml,*.fnt";
        //string searchPatternDir = "*";
        //var isDir = searchPatternDir.Equals(searchPattern);
        //GetStringEnvironmentArg("panel_");

        //int a = 1;
        //while (a > 0)
        //{
        //    a++;
        //    //Console.WriteLine(a);
        //}
        //Console.WriteLine(a - 1);

        //Type t = typeof(SimpleClass);
        //BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public |
        //                     BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
        //MemberInfo[] members = t.GetMembers(flags);
        //Console.WriteLine($"Type {t.Name} has {members.Length} members: ");
        //foreach (var member in members)
        //{
        //    string access = "";
        //    string stat = "";
        //    var method = member as MethodBase;
        //    if (method != null)
        //    {
        //        if (method.IsPublic)
        //            access = " Public";
        //        else if (method.IsPrivate)
        //            access = " Private";
        //        else if (method.IsFamily)
        //            access = " Protected";
        //        else if (method.IsAssembly)
        //            access = " Internal";
        //        else if (method.IsFamilyOrAssembly)
        //            access = " Protected Internal ";
        //        if (method.IsStatic)
        //            stat = " Static";
        //    }
        //    var output = $"{member.Name} ({member.MemberType}): {access}{stat}, Declared by {member.DeclaringType}";
        //    Console.WriteLine(output);
        //}





    }
}
// The example displays the following output:
//	Type SimpleClass has 9 members:
//	ToString (Method):  Public, Declared by System.Object
//	Equals (Method):  Public, Declared by System.Object
//	Equals (Method):  Public Static, Declared by System.Object
//	ReferenceEquals (Method):  Public Static, Declared by System.Object
//	GetHashCode (Method):  Public, Declared by System.Object
//	GetType (Method):  Public, Declared by System.Object
//	Finalize (Method):  Internal, Declared by System.Object
//	MemberwiseClone (Method):  Internal, Declared by System.Object
//	.ctor (Constructor):  Public, Declared by SimpleClass